package com.htjx.mall.controllers;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.htjx.mall.commons.api.Result;
import com.htjx.mall.commons.models.product.Specification;
import com.htjx.mall.services.SpecificationService;

@Controller
@RequestMapping("/specification")
public class SpecificationController {
	@Autowired
	private SpecificationService specificationService;
	/****
	 * 分页获取商品目录
	 */
	@RequestMapping(value = "/list", method = RequestMethod.GET, produces = "application/json")
	@ResponseBody
	public Result list(@RequestParam("catalog_id") long catalogId) {
		List<Specification> listSpecification = specificationService.SelectByCatalogId(catalogId);
		Result result = new Result(0, "查询成功");
		result.setBody(listSpecification);
		return result;
	}
	
	@RequestMapping(method = RequestMethod.GET, produces = "application/json")
	@ResponseBody
	public Result selectById(@RequestParam("id") long id) {
		Specification specification = specificationService.selectById(id);
		Result result = new Result(0, "查询成功");
		result.setBody(specification);
		return result;
	}
}
